﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using ClientWorkflowLibrary.DTRender;

namespace ClientWorkflowLibrary
{
    /// <summary>
    /// Given the proper meeting info, download all the talks for it!
    /// </summary>
    public partial class MarkTalkRenderDone : Activity
	{
        /// <summary>
        /// The actual rendering client that we can call back to.
        /// </summary>
        public DTRenderClient RenderClient
        {
            get { return (DTRenderClient)GetValue(RenderClientProperty); }
            set { SetValue(RenderClientProperty, value); }
        }

        // Using a DependencyProperty as the backing store for RenderClient.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty RenderClientProperty =
            DependencyProperty.Register("RenderClient", typeof(DTRenderClient), typeof(MarkTalkRenderDone), new PropertyMetadata(null));

        /// <summary>
        /// The ID of the talk that we've just finished rendering.
        /// </summary>
        public int TalkID
        {
            get { return (int)GetValue(TalkIDProperty); }
            set { SetValue(TalkIDProperty, value); }
        }

        // Using a DependencyProperty as the backing store for TalkID.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TalkIDProperty =
            DependencyProperty.Register("TalkID", typeof(int), typeof(MarkTalkRenderDone), new PropertyMetadata(-1));

        /// <summary>
        /// The number of talks that were rendered in this go around.
        /// </summary>
        public int NumberOfRenderedTalks
        {
            get { return (int)GetValue(NumberOfRenderedTalksProperty); }
            set { SetValue(NumberOfRenderedTalksProperty, value); }
        }

        // Using a DependencyProperty as the backing store for NumberOfRenderedTalks.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty NumberOfRenderedTalksProperty =
            DependencyProperty.Register("NumberOfRenderedTalks", typeof(int), typeof(MarkTalkRenderDone), new PropertyMetadata(0));



        /// <summary>
        /// Note that we are ready to do the next item.
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            ///
            /// Let the service know we are ready for the next talk!
            /// 

            RenderClient.RenderDone(TalkID, 100, NumberOfRenderedTalks);
            return ActivityExecutionStatus.Closed;
        }
	}
}
